
export default class UserLogic {
    constructor()
    {

    }
    private static _instance:UserLogic;
    
    public static get instance() : UserLogic {
        if (!this._instance)
        {
            this._instance = new UserLogic();
        }
        return this._instance
    }
    private _userObj:object = JSON.parse(cc.sys.localStorage.getItem('userData'));
    
    public get userObj() : object {
        return this._userObj
    }
    
    public initUserData(name:string,sex:number)
    {
        this._userObj = {}
        this._userObj["name"] = name
        this._userObj["sex"] = sex
        this._userObj["headId"] = ""
        this._userObj["money"] = 0
        this._userObj["gold"] = 0
        cc.sys.localStorage.setItem('userData', JSON.stringify(this._userObj));
    }

}
